package com.sk.weichat.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.sk.weichat.bean.circle.PublicMessage;

import java.util.List;

/**
 * @author lzs
 * @date 2019/10/22
 * Email:343067508@qq.com
 **/
public class DynamicBean extends PublicMessage implements MultiItemEntity, Parcelable {

    public static final String DynamicBean_Key = "DynamicBean";

    public static final int type_single_image = 0;//单图
    public static final int type_grid_image = 1;//多图

    public static final int type_voice = 2;//语音类型
    public static final int type_short_video = 3;//短视频类型

    public boolean isPrepareing = false;

    public int getRotation() {
        return rotation;
    }

    public void setRotation(int rotation) {
        this.rotation = rotation;
    }

    private  int rotation;//视频的旋转角度

    protected DynamicBean(Parcel in) {
        super(in);
        isPrepareing = in.readByte() != 0;
        ifAttention = in.readInt();
        rotation = in.readInt();
        videoHeight = in.readInt();
        videoWidth = in.readInt();
        topicNames = in.createStringArrayList();
        isActive = in.readByte() != 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        dest.writeByte((byte) (isPrepareing ? 1 : 0));
        dest.writeInt(ifAttention);
        dest.writeInt(rotation);
        dest.writeInt(videoHeight);
        dest.writeInt(videoWidth);
        dest.writeStringList(topicNames);
        dest.writeByte((byte) (isActive ? 1 : 0));
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<DynamicBean> CREATOR = new Creator<DynamicBean>() {
        @Override
        public DynamicBean createFromParcel(Parcel in) {
            return new DynamicBean(in);
        }

        @Override
        public DynamicBean[] newArray(int size) {
            return new DynamicBean[size];
        }
    };

    public int getIfAttention() {
        return ifAttention;
    }

    public void setIfAttention(int ifAttention) {
        this.ifAttention = ifAttention;
    }

    private int ifAttention;  //1=关注；2=好友；0=陌生人 ；-1=黑名单


    public int getVideoHeight() {
        return videoHeight;
    }

    public void setVideoHeight(int videoHeight) {
        this.videoHeight = videoHeight;
    }

    public int getVideoWidth() {
        return videoWidth;
    }

    public void setVideoWidth(int videoWidth) {
        this.videoWidth = videoWidth;
    }

    private int videoHeight;// 视频高度
    private int videoWidth;// 视频宽度


    public List<String> getTopicNames() {
        return topicNames;
    }


    public void setTopicNames(List<String> topicNames) {
        this.topicNames = topicNames;
    }

    private List<String> topicNames; //话题列表


    public boolean isActive() {
        return isActive;
    }

    public void setActive(boolean active) {
        isActive = active;
    }

    private boolean isActive = false;//是否需要播放（语音或者视频）

    public DynamicBean() {
    }


    @Override
    public int getItemType() {
        Body body = getBody();
        int type = body.getType();
        if (body.getType() == PublicMessage.TYPE_IMG) {
            //图片
            if (null != body && body.getImages() != null && body.getImages().size() > 1) {
                // Log.e("lzs", "type_grid_image");
                return type_grid_image;
            } else {
                // Log.e("lzs", "type_singe_image");
                return type_single_image;
            }
        } else if (type == PublicMessage.TYPE_VIDEO) {
            //视频
            return type_short_video;
        } else if (type == PublicMessage.TYPE_VOICE) {
            //语音
            return type_voice;
        }

        return 0;
    }

}
